package com.github.fancyideas.jwt;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/jwt")
public class JwtController {

    @Autowired
    private JwtConfigurationProperties jwtConfigurationProperties;

    @PostMapping("/refresh")
    public String refresh(HttpServletRequest request) {
        String oldToken = request.getHeader(jwtConfigurationProperties.getTokenHeader());
        return jwtConfigurationProperties.refreshToken(oldToken);
    }
}
